home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0124_Snow Screen Saver.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  3KB  |  81 lines

  1. {
  2. NB>{Hello All! I've recently coded this screen saver.It really looks like
  3. NB>snow is falling all over, don't you think?
  4.  
  5. Yeah, it looked pretty neat!
  6.  
  7. NB>However, I did not set out to do a snow screen saver and if you exp
  8. NB>with it a little you will see that it can even turn out to be a fir
  9. NB>If anyone can improve this code or make anything out of it, I would
  10. NB>very pleased to have a copy of the source.
  11.  
  12. Ok, I played around with it a bit today, and following is my modified
  13. version.  I pretty much just cleaned it up, got rid of all the unused
  14. variables and stuff (there were quite a few <G>) for readability,
  15. simplified a the calculations, and removed a lot of the overhead, and
  16. removed most of the global variables.  You will see that now you can
  17. have a lot more snowflakes without it bogging out.  I also removed the
  18. custom palette because you can get pretty much the same colours using
  19. the default palette (indexes 19-31).  It can probably be simplified
  20. even further (ie. remove the x and y tables and just use newPos table).
  21. Oh yeah, I threw in a little snowflake explosion at the start too :-).
  22.  
  23. (********************************************************************
  24.  Originally by    : Nick Batalas, 14-6-1994
  25.  Modifications by : Eric Coolman, 19-6-1994
  26. ********************************************************************)
  27. }
  28.  
  29. Program SnowFall;
  30. Uses crt;                                  { for keypressed only }
  31.  
  32. const
  33.   Flakes = 500;            { try less flakes for faster snowfall }
  34.  
  35. {---------------- Stuff not specific to snowfall ----------------}
  36. Procedure vidMode(mode : byte);assembler;
  37.   asm mov ah,$00;  mov al,mode; int 10h; end;
  38.  
  39. Procedure setPixel(pixPos : word; color : byte);
  40. begin
  41.     mem[$A000:pixPos] := color;
  42. end;
  43.  
  44. {---------------------------MAIN PROGRAM-------------------------}
  45.  
  46. var
  47.   CurFlake : integer;                        { snowflake counter }
  48.   i : longint;                       { to add velocity to flakes }
  49.   x,y, newPos: array[0..Flakes] of word;         { lookup tables }
  50. BEGIN
  51.   randomize;
  52.   for curFlake:=0 to Flakes do        { set up snow lookup table }
  53.   begin
  54.     x[curFlake]:=random(319);
  55.     y[curFlake]:=random(199);
  56.   end;
  57.  
  58.   vidMode($13);                       { 320x200x256 graphics mode }
  59.  
  60.   i := 0; { change to 100 or higher to get rid of start explosion }
  61.  
  62.   repeat
  63.     inc(i);
  64.  
  65.     for curFlake:=0 to Flakes do
  66.       begin
  67.         setPixel(newPos[curFlake], 0);     { erase old snowflake }
  68.         newPos[curFlake] :=      { set up and draw new snowflake }
  69.           round(x[curFlake]*(i*0.01)) +                  { new X }
  70.           round(y[curFlake]*(i*0.01)) * 320;             { new Y }
  71.         setPixel(newPos[curFlake], (curFlake mod 13) + 19);
  72.       end;
  73.  
  74.     while (port[$3da] and $08) = $08 do;  { wait for vRetrace to }
  75.     while (port[$3da] and $08) = $00 do;  { start and end        }
  76.   until keypressed;
  77.  
  78.   vidMode($03);                       { return to 80x25 textmode }
  79. end.
  80.  
  81.